<meta charset="UTF-8">
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * @todo 修改完密码之后重新登录
 * @remark 陈国俊的那堂数据库课程设计动员大会之后，发现自己对于“登陆”和“登录”特别敏感，生怕自己打错
 */

include ("conn/conn.php");

$conn = prepare();

session_start();

$name=$_SESSION['username'];

$password1=$_POST['password1'];
$password2=$_POST['password2'];

//$sql=mysql_query("select * from tb_user where name='".$this->name."'",$conn);
$sql = exectue_sql_statement($conn, "select * from Members where members_name='$name'");
$info=sqlsrv_fetch_array($sql);
if($info['members_password']!=$password1) {
echo "<script>alert('原密码输入错误!');history.back();</script>";
exit;
} else {
//mysql_query("update tb_user set pwd='".md5($this->p2)."' ,pwd1='$this->p2' where name='$this->name'",$conn);
exectue_sql_statement($conn, "update Members set members_password='$password2' where members_name='$name'");
echo "<script>alert('密码修改成功!');history.back();</script>";
exit;
}
?>